var login = new Vue({
  el: '#login',
  data:{
    user:null,
		username:'',
		password:'',  
  },
  mounted:function(){
  	//this.username = 'zs'
  	//this.password = 'root'
  	//this.login()
  },
  methods:{
	login:function(){
		if(this.username.length == 0) {
			mui.toast("请输入用户名")
			return;
		}
		if(this.password.length == 0) {
				mui.toast("请输入密码")
			return;
		}
		plus.nativeUI.showWaiting( "登录中..." );

		mui.ajax(sever+'/mlogin', {
			data: {
				username: this.username,
				password: this.password,
				mobileLogin:true
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 10000, //超时时间设置为10秒；
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			success: function(data) {
			plus.nativeUI.closeWaiting(); 
				mui.toast(data.message);
				//登录成功
				if(data.status){
					//设置用户
					localStorage.localuserid=data.user.id;
					localStorage.localname=data.user.name;
					localStorage.localloginname=data.user.loginName;
					//用户
					//window.location.href='index.html'; 
					mui.back()
				}
			},
			error: function(xhr,type,errorThrown){
				plus.nativeUI.closeWaiting(); 
				if (type == 'timeout') {
					mui.toast('登录超时，请稍后再试');
					return ;
				}
				mui.toast('登录发生错误');
					return ;
			}
		});
	
	}
  },
});